package com.example.kuaizu.mapper;

import com.example.kuaizu.pojo.ov.OliveBranchVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;
import java.util.Set;

/**
 * @author: wangmx15
 * @date: 2025/9/20
 **/
@Mapper
public interface OliveBranchMapper {

    @Select("SELECT * ,gratis_count + purchases_count AS count FROM olive_branch where openid = #{openid}")
    OliveBranchVo selectByOpenId(String openid);
    @Update("update olive_branch set gratis_count = (gratis_count-1) , use_count = (use_count+1) where openid = #{openid}")
    void updateMyoliveBranchGratisCount(String openid);

    @Update("update olive_branch set purchases_count = (purchases_count-1)  ,use_count = (use_count+1)where openid = #{openid}")
    void updateMyoliveBranchPurchasesCount(String openid);

    @Update("update olive_branch set gratis_count = 3 ")
    void oliveBranchResetEveryDay();

    @MapKey("openId")
    Map<String,String> selectNotOlivBranch();

    int insertOliveBranchs(Set<String> list);
}
